<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h1>简单计算器</h1>
        <input type="text" v-model.number='a'> + <input type="text" v-model.number='b'> = <span>{{res}}</span>
    </div>
    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript">
        /*
                                                                                                                                         要求: 实时计算两数之和
                                                                                                                                       */
        var vm = new Vue({
            el: '#app',
            data: {
                a: '',
                b: '',
                res: ''
            },
            methods: {},
            watch: {
                a: function() {
                    this.res = this.a + this.b
                },
                b: function() {
                    this.res = this.a + this.b
                }
            }
        });
    </script>
</body>

</html>